﻿create procedure dbo.SubscribeAudience
(
		@UserID int,
		@AudienceID int
	)

AS

DECLARE @iCount int

SET @iCount = (SELECT Count(UserID) FROM dbo.AudienceMembers WHERE UserID = @UserID AND AudienceID = @AudienceID)

IF @iCount = 0
	BEGIN

		INSERT INTO dbo.AudienceMembers
                      (UserID, AudienceId, CreatedOn)
		VALUES     (@UserID,@AudienceID, GETDATE())

	END
	
RETURN


